home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
howtod2r
/
queue.cls
< prev
next >
Wrap
Text File
|
1999-01-12
|
1KB
|
53 lines
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "queue"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
'Queue.cls
Private Q() As Variant
Private Front As Integer
Private Rear As Integer
Private QueueSize As Integer
Public Function EmptyQ() As Boolean
EmptyQ = (Rear = Front)
End Function
Public Sub ClearQ(QSize As Integer)
ReDim Q(QSize)
Front = QSize
Rear = QSize
QueueSize = QSize
End Sub
Public Sub EnQ(NewVal As Variant)
If Rear = QueueSize Then
Rear = 1
Else
Rear = Rear + 1
End If
Q(Rear) = NewVal
End Sub
Public Sub DeQ(Entry As Variant)
If Front = QueueSize Then
Front = 1
Else
Front = Front + 1
End If
Entry = Q(Front)
End Sub